﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace crm_library.DataAccess.TableReps
{
	[AttributeUsage(AttributeTargets.Property, AllowMultiple=false, Inherited=false)]
	public class DataFieldAttribute : Attribute
	{
		public bool IsPK { get; private set; }
		public bool AllowNulls { get; private set; }
		public string ColumnName { get; private set; }

		/// <summary>
		/// Flags a Property as existing in the database. Flagged properties must have public setters.
		/// </summary>
		/// <param name="fieldName">Name of column in the database table</param>
		/// <param name="allowNulls">Does the column allow null values?</param>
		/// <param name="isPK">Is the column a Primary key on the database?</param>
		public DataFieldAttribute(string columnName, bool allowNulls = true, bool isPK = false)
		{
			ColumnName = columnName;
			AllowNulls = allowNulls;
			IsPK = isPK;
		}

	}
}
